﻿using DogModel;
using IDogService;
using Microsoft.AspNetCore.Mvc;

namespace DogAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        protected readonly ITestService testService;
        protected readonly ILogger<TestController> Nlog;

        public TestController(ITestService test, ILogger<TestController> logger)
        {
            testService = test;
            Nlog = logger;
        }

        [HttpGet("Creat")]
        public bool Creat()
        {
            //Nlog.LogInformation("调用了TestController里的Creat方法:向数据库新增一条数据.");
            return testService.Creat(new DogModel.TestInfo() { I = 1, J = 2, S = 3 });
        }

        [HttpGet("GetAll")]
        public List<TestInfo> GetAll()
        {
            //Nlog.LogInformation("调用了TestController里的GetAll方法:获取TestInfo表全部的数据.");
            return testService.GetAll();
        }

        [HttpGet("GetAOP")]
        public List<TestInfo> GetTestInfo()
        {
            return testService.GetTestInfo();
        }
    }
}